Token Formatting--Numeric

You can use .NET formatting specifiers to have data stored in tokens automatically formatted to specified numeric settings. Standard format specifiers can be used to format numbers according to some of the most frequently used choices. Custom format specifiers will work for the same options allowed by the standard ones and also allow you to further customize or combine formatting choices. You can type these specifiers directly in the tokens or use the Token Editor to insert the specifier and test the formatted token.

Example: Lisa is processing order forms. She wants to use the numbers in the "Order" field as document names. The order numbers can have various numbers of digits, so she wants to add leading zeros so the names will be sorted in true numeric order. Currently, the maximum number of digits in an order number is five, but she decides to allow eight digits so she can continue to use the same system well into the future. She can do this using either standard or custom numeric format specifiers. In either case, she can begin by opening the Token Editor and selecting Apply Formatting. Then she can use either of the following options:

Formatting Specifier Resulting Token Result when tested with "334"
Standard D8 %(Order#"D8"#) 00000334
Custom 00000000 %(Order#"00000000"#) 00000334

Note: The regional settings such as date and currency are Windows regional settings found in the Control Panel for the computer running the Workflow Server.

Standard Numeric Format Specifiers

The following specifiers can be used to format numbers according to standard rules.

Example: Maggie creates a workflow that retrieves values from lab reports saved as PDF forms. The reports include numbers in decimal form that she wants to store as percentages in Laserfiche fields.

Formatting specifier Formatted token Test value Result
P %(RetrievePDFFormContents_Lab Number1#"P"#) .12 12.00 %

 

Specifier Type Function
C or c Currency Formats the value to the local currency settings.
D or d Decimal Formats the part of the number before any decimal point. Specify a minimum number of digits. Example: D8 for a minimum of eight digits. Leading zeroes will be appended to create the appropriate number of digits.
E or e Exponent Specify a number of digits after the decimal point for a number in exponential format. Example: e3 for three digits after the decimal. The number 12345.6789 will be formatted 1.234e+004
F or f Fixed point Formats the part of the number after the decimal point. Specify the desired number of decimal places. Example: F3 for three digits after the decimal. Zeroes will be used to create the appropriate number if necessary.
P or p Percent Converts the value to a percentage.

Custom Numeric Format Specifiers

The following specifiers can be combined to format numbers to specific patterns.

Example: Homer's workflow retrieves values from the field "Measurement." He wants to format the value of the corresponding token so that the numbers before the decimal place have a comma separating the thousands place, if one exists, but he does not want to append leading zeroes. He also wants the numbers to have exactly four digits after the decimal, even if that means appending zeroes.

Formatting specifier Formatted token Test value Result
#,###.0000 %(RetrieveFieldValues_Measurement#"#,###.0000"#) 1425.99 1,425.9900
#,###.0000 %(RetrieveFieldValues_Measurement#"#,###.0000"#) 623.877 623.8770

 

Specifier Type Function
0 Zero placeholder Will be replaced if there is a value in that position; otherwise, will appear as a 0 in the result.
# Digit placeholder Will be replaced if there is a value in that position; otherwise, nothing will appear.
. Decimal point Represents the location of the decimal separator. Only the first decimal point in a string will be used.
, Thousand separator and number scaling Can be used to insert commas as a thousands separator in numbers. Also, one or more immediately to the left of the explicit or implicit decimal point can be used to display numbers in terms of some other amount (e.g., The format 0,, applied to 3,000,000 is 3).
% Percentage placeholder Multiplies a number by 100 and inserts a % sign.
E0, E+0, E-0, e0, e+0, e-0 Scientific notation Formats the number using scientific notation. The number of 0 characters indicates the minimum number of digits to output for the exponent.
\ Escape character Causes the following character to be used literally, even if it is otherwise one of the formatting specifiers.
'ABC' or "ABC" Literal string The characters inside single or double quotation marks (excepting the quotation marks around the entire expression) will be used in the result as is, and do not affect formatting. Example: Paul's ID number is 435. The token %(ID Number#"0000"#) returns 0435. The token %(ID Number#"'D'0000"#) returns D0435.
; Section separator Used to separate formats for positive, negative, and zero numbers in the format string. Using these, you can specify three different types of formats to be applied depending on the type of number. Positive numbers and zeros are formatted according to the first section (before the first semicolon), negative numbers are formatted according to the second section, and zeros are formatted according to the third section. If you leave the second section blank, then the first section will apply to all nonzero numbers.

To learn more about .NET numeric formatting specifiers, see the Microsoft Docs site at:

https://docs.microsoft.com/en-us/dotnet/standard/base-types/standard-numeric-format-strings

and

https://docs.microsoft.com/en-us/dotnet/standard/base-types/custom-numeric-format-strings